<%@ page import="com.bdqn.zhang.pojo.Vivoproduct" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!--360浏览器优先以webkit内核解析-->

    <title>H+ 后台主题UI框架 - 主页示例</title>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="static/js/plugins/layui/css/layui.css">
    <link href="static/css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="static/css/bootstrap.min.css?v=3.3.7" rel="stylesheet"/>
    <link href="static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="static/css/animate.css" rel="stylesheet"/>
    <link href="static/css/style.css?v=4.1.0" rel="stylesheet"/>
    <style>
        #demo1 {
            width: 100px;
            height: 100px;
        }

        .ibox-title {
            min-height: 15px;
        }

        .ml_20 {
            margin-left: 20px;
        }

        .w100 {
            width: 100px !important;
        }

        .mt-60 {
            margin-top: -60px;
        }

        .layui-table-cell {

            text-align: center;

            height: auto;

            white-space: normal;

        }

        .layui-table img {
            max-width: 300px
        }

        .tishi {
            color: red;
        }
    </style>
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="demoTable">
                    搜索：
                    <div class="layui-inline">
                        <input class="layui-input" name="id" id="demoReload" autocomplete="off">
                    </div>
                    <select style="height: 38px; border: darkgrey" class="ipt" id="role" name="city" lay-verify="">
                        <option value="全查询">全查询</option>
                        <option value="仅查询用户名">仅查询商品名称</option>
                        <option value="仅查询手机号">仅查询商品介绍</option>
                        <option value="仅查询性别">仅查询商品价格</option>
                        <option value="仅查询邮箱">仅查询商品上架时间</option>
                        <option value="通过状态查询">通过状态查询</option>
                    </select>
                    <button class="layui-btn" data-type="reload" id="ss">查询</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight mt-60">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <table class="layui-hide" id="test" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="static/js/jquery-3.6.1.js"></script>
<script src="static/js/bootstrap.min.js?v=3.3.7"></script>
<script src="static/js/plugins/layer/layer.min.js"></script>
<script src="static/js/plugins/layui/layui.js"></script>

<!-- 自定义js -->
<script src="static/js/content.js"></script>


<!-- Peity -->
<script src="static/js/demo/bootstrap-table-demo.js"></script>

<!-- 欢迎信息 -->
<script src="static/js/welcome.js"></script>

<%--	<script type="text/html" id="checkboxTpl">--%>
<%--		<!-- 这里的 checked 的状态只是演示 -->--%>
<%--	<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id==10006 ? 'checked' : ''--%>
<%--		}}>--%>
<%--	</script>--%>
<%--	<script type="text/html" id="barTb">--%>
<%--		<a class="layui-btn layui-btn-warm" lay-event="add">添加</a>--%>
<%--		<a class="layui-btn layui-btn-danger" lay-event="delete">批量删除</a>--%>
<%--	</script>--%>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 上架商品</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delAll"> 批量下架</button>
    </div>
</script>
>
<%--	<script type="text/html" id="checkboxTpl">--%>
<%--		<!-- 这里的 checked 的状态只是演示 -->--%>
<%--		<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id == 10006 ? 'checked' : '' }}>--%>
<%--	</script>--%>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">下架商品</a>
</script>
<script id="showScreenhost" type="text/html">
    {{# var srr=d.imglbt.split(",");
    for(var j in srr) { srr[j] }}
    <div class="imglbt"
         style="margin:0 10px; display:inline-block !important; display:inline;  max-width:70px; max-height:50px;">
        <img style=" max-width:70px; max-height:50px;" src="{{srr[j]}}"/>
    </div>
    {{# } }}
</script>
<script id="showScreenhosts" type="text/html">
    {{# var srr=d.imgzst.split(",");
    for(var j in srr) { srr[j] }}
    <div style="margin:0 10px; display:inline-block !important; display:inline;  max-width:70px; max-height:50px;">
        <img style=" max-width:70px; max-height:50px;" src="{{srr[j]}}"/>
    </div>
    {{# } }}
</script>
<script>
    window.name = "upload";
    layui.use(['form', 'upload', 'table', 'element', 'layer', 'laydate'], function () {
        let $ = layui.jquery
        let upload = layui.upload
        let element = layui.element
        let layer = layui.layer;
        let laydate = layui.laydate;
        let table = layui.table;
        var form = layui.form
        laydate.render({
            elem: '#grounding_date'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
            , range: ['#grounding_date_from', '#grounding_date_to']
        });
        //多图文件上传
        var uploadInst2 = upload.render({
            elem: '#upload_2'
            , url: "gly?opr=upload" //多图上传接口
            , multiple: true
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload_list').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" style="width: 100px;height: 100px;" onclick="showimg(this)">')
                    $('#control_img_del').css('display', 'inline');
                    $('#control_img').css('display', 'inline');
                });
            }
            , done: function (data) {
                //上传失败
                if (data.code > 0) {
                    return layer.msg('上传失败');
                } else {
                    //上传成功
                    var last_url = document.getElementById("picText_2").value;
                    var upload_url = "";
                    if (last_url !== "") {
                        upload_url = last_url + "," + "static/img/手机展示/" + data.imgSrc;
                    } else {
                        upload_url = "static/img/手机展示/" + data.imgSrc;
                    }
                    document.getElementById("picText_2").value = upload_url;
                    //将后台获取的图片地址传到前台存入隐藏控件中，随着表单一起提交
                    document.getElementById("H_img").value = upload_url;
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText2 = $('#demoText2');
                demoText2.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText2.find('.demo-reload').on('click', function () {
                    uploadInst2.upload();
                });
            }
        });
        //删除多张图片
        $('#control_img_del').click(function () {
            $("#upload_listss").find("img").remove();
            document.getElementById("picText_2").value = "";
            $('img[class=layui-upload-img]').css('display', 'none');
            $('#control_img_del').css('display', 'none');
            $('#control_img').val('');
            document.getElementById("H_img").value = "";
        })

        //多图文件上传
        var uploadInst2 = upload.render({
            elem: '#upload_1'
            , url: "gly?opr=upload" //多图上传接口
            , multiple: true
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload_lists').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" style="width: 100px;height: 100px;" onclick="showimg(this)">')
                    $('#control_img_dels').css('display', 'inline');
                    $('#control_imgs').css('display', 'inline');
                });
            }
            , done: function (data) {
                //上传失败
                if (data.code > 0) {
                    return layer.msg('上传失败');
                } else {
                    //上传成功
                    var last_url = document.getElementById("picText_1").value;
                    var upload_url = "";
                    if (last_url !== "") {
                        upload_url = last_url + "," + "static/img/手机展示/" + data.imgSrc;
                    } else {
                        upload_url = "static/img/手机展示/" + data.imgSrc;
                    }
                    document.getElementById("picText_1").value = upload_url;
                    //将后台获取的图片地址传到前台存入隐藏控件中，随着表单一起提交
                    document.getElementById("H_img").value = upload_url;
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText2 = $('#demoText1');
                demoText2.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText2.find('.demo-reload').on('click', function () {
                    uploadInst2.upload();
                });
            }
        });
        //删除多张图片
        $('#control_img_dels').click(function () {
            $("#upload_lists").find("img").remove();
            document.getElementById("picText_1").value = "";
            $('img[class=layui-upload-img]').css('display', 'none');
            $('#control_img_dels').css('display', 'none');
            $('#control_imgs').val('');
            document.getElementById("H_img").value = "";
        })
        //上传文件
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'spcx?opr=upload' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
                element.progress('demo', '0%'); //进度条复位
                layer.msg('上传中', {icon: 16, time: 0});
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                // 给隐藏表单赋值
                $("#photo").val(res.imgSrc);
                $('#demoText').html('');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
            //进度条
            , progress: function (n, elem, e) {
                element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                if (n == 100) {
                    layer.msg('上传完毕', {icon: 1});
                }
            }
        });
//初始化时查询
        let tableIns = table.render({
            elem: '#test',
            height: 480,
            url: 'spcx?opr=getAll',
            page: true,
            skin: 'line',
            toolbar: '#toolbarDemo',
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', title: '编号', sort: true,hide: true},
                {field: 'eid', title: 'eid', sort: true, hide: true},
                {field: 'yid', title: 'yid', sort: true, hide: true},
                {field: 'etype', title: '商品名称', align: 'center', sort: true},
                {field: 'descs', title: '介绍', align: 'center', sort: true},
                {field: 'img', title: '商品主图', align: 'center', templet: function (d) {
                        return '<img onclick="showimg(this)" id="driimg" style="display: inline-block; width: 50px; height: 50px;" src="' + d.img + '">';
                    }
                },
                {field: 'imglbt', title: '轮播图', align: 'center', templet: '#showScreenhost', hide: true},
                {field: 'imgzst', title: '轮播图展示', align: 'center', templet: '#showScreenhosts', hide: true},
                {field: 'image', title: '价格', align: 'center', sort: true},
                {field: 'pv', title: '点击量', align: 'center', sort: true},
                {field: 'kc', title: '库存', align: 'center', sort: true},
                {
                    field: 'status', title: '状态', align: 'center', sort: true, templet: function (d) {
                        var e = d.status;
                        if (e == 0) {
                            e = '<a style="color: #ed2a4a" lay-event="jin">下架状态 </a>';
                            return e;
                        } else if (e == 1) {
                            e = '<a style="color: #00FF00" lay-event="jin">上架状态</a>';
                            return e;
                        } else if (-1 == e) {
                            e = '<a style="color: #eea236" lay-event="jin">预售状态</a>';
                            return e;
                        }
                    }
                },
                {field: 'add_time', align: 'center', title: '时间', sort: true},
                {title: '操作', align: 'center', width: "17%", toolbar: '#barDemo'}]]
        })
        table.on('toolbar(test)', function (obj) {
            switch (obj.event) {  // 监听添加操作
                case 'add':// 监听添加操作
                    let index = layer.open({
                        title: '上架商品',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['100%', '100%'],
                        content: 'addsp.jsp',
                        end: function () {
                            location.reload();
                        }
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    break;
                case 'delAll':
                    var checkStatus = table.checkStatus('test'),
                        data = checkStatus.data,
                        userId = "";
                    if (data.length > 0) {
                        for (var i in data) {
                            userId += data[i].yid + ",";
                        }
                        console.log(userId);//打印获取到选中的id，用，分割
                        layer.confirm('确定下架选中的商品？', {icon: 3, title: '提示信息'}, function (index) {
                            $.ajax({
                                url: "spcx?opr=del",
                                type: "POST",
                                data: {id: userId},
                                success: function (msg) {
                                    if (msg == "true") {
                                        layer.msg('下架成功!', {icon: 1, time: 1000});
                                        tableIns.reload({
                                            page: {
                                                curr: 1
                                            }
                                        });
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="商品操作";
                                        let gn="商品批量下架";
                                        let jg="成功";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                        top.window['hsz'].frames.location.reload();
                                        top.window['butt'].frames.location.reload();
                                        top.window['lode'].frames.location.reload();
                                    } else {
                                        layer.msg('下架失败', {time: 1000});
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="商品操作";
                                        let gn="商品批量下架";
                                        let jg="失败";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                    }
                                }
                            });
                        });
                    } else {
                        layer.msg('请选择下架的商品!', {icon: 1, time: 1000});  //如果未选择数据，则提示。
                    }
                    break;
            }
        });
        //条件查询
        $("#ss").click(function () {
            var p_name = $(".layui-input").val()
            var myselect = document.getElementById("role");
            var index = myselect.selectedIndex;// selectedIndex是所选中的项的index
            myselect.options[index].value;
            let rr = myselect.options[index].text;
            if (p_name == null || p_name == "") {
                tableIns.reload({
                    url: 'spcx?opr=getAll',
                    page: {
                        curr: 1
                    }
                });
            } else if(rr == '通过状态查询' && p_name !== null || p_name !== ""){
                if (p_name == "下架状态" || p_name == "上架状态" || p_name == "预售状态") {
                    tableIns.reload({
                        url: 'spcx?opr=ztcx',
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                } else if (rr == '全查询' && p_name !== null && p_name !== "") {
                    tableIns.reload({
                        url: 'spcx?opr=getAll2',
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                }else if (rr == '仅查询商品名称' && p_name !== null || p_name !== "") {
                    tableIns.reload({
                        url: 'spcx?opr=bg&rr=' + rr,
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                } else if (rr == '仅查询商品介绍' && p_name !== null || p_name !== "") {
                    tableIns.reload({
                        url: 'spcx?opr=bg&rr=' + rr,
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                } else if (rr == '仅查询商品价格' && p_name !== null || p_name !== "") {
                    tableIns.reload({
                        url: 'spcx?opr=bg&rr=' + rr,
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                } else if (rr == '仅查询商品上架时间' && p_name !== null || p_name !== "") {
                    tableIns.reload({
                        url: 'spcx?opr=bg&rr=' + rr,
                        where: {
                            p_name: p_name,
                        },
                        page: {
                            curr: 1
                        }
                    })
                }
            }
        })

        table.on('tool(test)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case'del':
                    layer.confirm('真的下架吗', function (index) {
                        $.ajax({
                            "url": "spcx?opr=del",
                            "dataType": 'text',
                            "type": 'post',
                            "data": {id: obj.data.yid},
                            async: false,
                            "success": function (date) {
                                if (date == "true") {
                                    layer.msg('下架成功', {icon: 1, time: 1500}, function () {
                                        tableIns.reload({
                                            where: {},
                                            page: {
                                                curr: 1
                                            }
                                        });
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="商品操作";
                                        let gn="商品下架";
                                        let jg="成功";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                        top.window['hsz'].frames.location.reload();
                                        top.window['butt'].frames.location.reload();
                                        top.window['lode'].frames.location.reload();
                                    });
                                } else {
                                    layer.msg('删除失败', {icon: 2, time: 1500});
                                    let b=sessionStorage.obs;
                                    let a=b.replace(/\"/g, "");
                                    let cz="商品操作";
                                    let gn="商品下架";
                                    let jg="失败";
                                    $.ajax({
                                        "url": "gly?opr=xmr",
                                        "data": {name:a,cz:cz,gn:gn,jg:jg}
                                    })
                                }
                            }
                        });
                        // layer.close(index);
                    });
                    break;
                case 'edit':
                    if (obj.data.status == 0) {
                        layer.msg('您的商品处于下架状态 无法修改', {icon: 1, time: 1500}, function () {
                        });
                    } else {
                        layer.open({
                            title: '编辑用户',
                            type: 1,
                            shade: 0.2,
                            maxmin: true,
                            shadeClose: true,
                            area: ['100%', '100%'],
                            content: $("#editForm"),
                            success: function () {
                                //进后台查找类型
                                $.ajax({
                                    "url": "spcx?opr=leixbj",
                                    "type": 'post',
                                    "data": {id: obj.data.yid},
                                    async: false,   //如果不加，无法实现数据传值
                                    "dataType": 'json',
                                    "success": function (datajson) {
                                        $("#roleId").find("option").remove();
                                        var select = $("#cRoleName");
                                        $(datajson).each(function (key) {  //循环读取后台传来的Json数据
                                            var roleName = datajson[key].etype;
                                            //调用自定义方法
                                            AppendNodes(roleName, roleName);//将value和text添加到下拉框中
                                        });
                                    },
                                    error: function () {
                                        alert("出现错误");
                                    }
                                })

                                function AppendNodes(value, text) {
                                    $("#roleId").append("<option  value='" + value + "'  name='rr' id='rr'>" + text + "</option>");
                                }

                                $("#id").val(obj.data.id);
                                $("#ms").val(obj.data.descs);
                                $("#jg").val(obj.data.image);
                                $("#sj").val(obj.data.title);
                                $("#kc").val(obj.data.kc);
                                $("#status").val(obj.data.status)
                                $("#sp").val(obj.data.etype);
                                document.getElementById("demo1").src = obj.data.img;
                                let url = obj.data.img;
                                var index = url.lastIndexOf("\/");
                                strs = url.substring(index + 1, url.length);
                                $("#photo").val(strs);


                                // $("#upload_listss").find("img").remove();
                                // var srr = data.imglbt.split(",");
                                // for (var j in srr) {
                                //     $('#upload_listss').append('<img src="' + srr[j] + '"  class="layui-upload-img" style="width: 100px;height: 100px;" onclick="showimg(this)">')
                                // }
                                // document.getElementById("picText_2").value = data.imglbt;
                                // $("#upload_lists").find("img").remove();
                                // var srrd = data.imgzst.split(",");
                                // for (var js in srrd) {
                                //     $('#upload_lists').append('<img src="' + srrd[js] + '"  class="layui-upload-img" style="width: 100px;height: 100px;" onclick="showimg(this)">')
                                // }
                                // document.getElementById("picText_1").value = data.imgzst;

                                form.render();
                            },
                        });
                    }
                    break;
                case 'jin':
                    layer.confirm('确定要做此操作吗', function (index) {
                        $.ajax({
                            "url": "spcx?opr=ztxg",
                            "dataType": 'text',
                            "type": 'post',
                            "data": {id: obj.data.id, zhi: obj.data.status},
                            async: false,
                            "success": function (date) {
                                if (date == "true") {
                                    layer.msg('修改成功', {icon: 1, time: 1500}, function () {
                                        let b=sessionStorage.obs;
                                        let a=b.replace(/\"/g, "");
                                        let cz="商品操作";
                                        let gn="商品状态修改";
                                        let jg="成功";
                                        $.ajax({
                                            "url": "gly?opr=xmr",
                                            "data": {name:a,cz:cz,gn:gn,jg:jg}
                                        })
                                        tableIns.reload({
                                            where: {},
                                            page: {
                                                curr: 1
                                            }
                                        });
                                    });
                                } else {
                                    layer.msg('修改失败', {icon: 2, time: 1500});
                                    let b=sessionStorage.obs;
                                    let a=b.replace(/\"/g, "");
                                    let cz="商品操作";
                                    let gn="商品状态修改";
                                    let jg="失败";
                                    $.ajax({
                                        "url": "gly?opr=xmr",
                                        "data": {name:a,cz:cz,gn:gn,jg:jg}
                                    })
                                }
                            }
                        });
                        layer.close(index);
                    });
                    break;
            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var p_name = $("#jg").val();
            if (p_name == "0" || p_name == 0) {
                $(".tishi").text("请输入价格").show(200);
                $(".tishi").delay(2500).hide(200);
            } else {
                    let post_data = $("form").serialize();
                    $.ajax({
                        "url": "spcx?opr=addSave2",
                        "dataType": 'text',
                        "type": 'post',
                        "data": post_data,
                        async: false,
                        "success": function (date) {
                            if (date == "true") {
                                layer.msg('修改成功', {icon: 1, time: 1500}, function () {
                                    let b=sessionStorage.obs;
                                    let a=b.replace(/\"/g, "");
                                    let cz="商品操作";
                                    let gn="商品修改";
                                    let jg="成功";
                                    $.ajax({
                                        "url": "gly?opr=xmr",
                                        "data": {name:a,cz:cz,gn:gn,jg:jg}
                                    })
                                    // 关闭弹出层
                                    layer.closeAll();
                                    tableIns.reload({
                                        page: {
                                            curr: 1
                                        }
                                    });
                                    top.window['butt'].frames.location.reload();
                                    top.window['lode'].frames.location.reload();
                                });
                            } else {
                                layer.msg('修改失败', {icon: 2, time: 1500});
                                let b=sessionStorage.obs;
                                let a=b.replace(/\"/g, "");
                                let cz="商品操作";
                                let gn="商品修改";
                                let jg="失败";
                                $.ajax({
                                    "url": "gly?opr=xmr",
                                    "data": {name:a,cz:cz,gn:gn,jg:jg}
                                })
                            }
                        }
                    });
            }
            return false;
        });
    })

    function showimg(t) {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '516px',
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: '<img style="display: inline-block; width: 100%; height: 100%;" src="' + t.src + '">'
        });
    }

</script>
<form id="editForm" method="post" style="display:none;">

    <div class="layui-form layuimini-form">
        <input type="hidden" name="id" id="id">
        <input type="hidden" name="status" id="status">
        <div class="layui-form-item">
            <label class="layui-form-label required">类型</label>
            <div class="layui-input-block">
                <select style="width: 180px;height: 30px;" class="ipt" id="roleId">
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">商品名称</label>
            <div class="layui-input-block">
                <input type="text" name="sp" lay-verify="required" lay-reqtext="商品名称不能为空" placeholder="请输入商品名称"
                       value="" class="layui-input" id="sp">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" required>描述</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" type="text" name="miaosu" lay-verify="required"
                          lay-reqtext="描述不能为空" id="ms"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">价格</label>
            <div class="layui-input-block">
                <input type="text" name="jg" lay-verify="required" lay-reqtext="价格必填" placeholder="请输入价格" value=""
                       class="layui-input" id="jg"><span class="tishi"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">库存</label>
            <div class="layui-input-block">
                <input type="text" name="kc" lay-verify="required" lay-reqtext="库存必填" placeholder="请输入库存" value=""
                       class="layui-input" id="kc"><span class="tishi1"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">主图</label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="test1">上传图片</button>
                <div class="layui-upload-list">
                    <img onclick="showimg(this)" class="layui-upload-imgs" id="demo1">
                    <p id="demoText"></p>
                </div>
                <div style="width: 95px;">
                    <div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="demo">
                        <div class="layui-progress-bar" lay-percent=""></div>
                    </div>
                </div>
                <input type="hidden" name="status" id="zhuangtai">
            </div>
        </div>
        <%--    隱藏表单 存储上传成功后 回调返回的文件名--%>
        <input type="hidden" name="photo" id="photo"><br>

        <div class="layui-upload">
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                <button type="button" class="layui-btn" id="upload_2"><i class="layui-icon">&#xe64a;</i>轮播图上传</button>
                <button type="button" class="layui-btn layui-btn-danger cover" id="control_img_del"
                        style="display: inline"><i class="layui-icon">&#xe640;</i>删除图片
                </button>
                <input type="hidden" id="control_img" value="{$detail.control_video}" name="control_video"/>
                <input type="hidden" id="temp_url_idimg" value="" name="temp_url_idimg"/>
            </blockquote>
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                预览图：
                <div class="layui-upload-list" id="upload_listss"></div>
                <input type="hidden" name="images_str" id="picText_2" class="upload_image_url" value="">
            </blockquote>
        </div>
        <div class="layui-upload">
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                <button type="button" class="layui-btn" id="upload_1"><i class="layui-icon">&#xe64a;</i>预览图上传</button>
                <button type="button" class="layui-btn layui-btn-danger cover" id="control_img_dels"
                        style="display: inline"><i class="layui-icon">&#xe640;</i>删除图片
                </button>
                <input type="hidden" id="control_imgs" value="{$detail.control_video}" name="control_video"/>
                <input type="hidden" id="temp_url_idimgs" value="" name="temp_url_idimg"/>
            </blockquote>
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                预览图：
                <div class="layui-upload-list" id="upload_lists"></div>
                <input type="hidden" name="images_strs" id="picText_1" class="upload_image_url" value="">
            </blockquote>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" id="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</form>
</body>

</html>